<template>
  <div class="answer-key">
    <div class="tabs">
      <div class="tab active">推荐答案</div>
      <div class="hide-answer" @click="toggleHideAnswer">
        <i class="icon-eye"></i>
        {{ isHidden ? '显示答案' : '隐藏答案' }}
      </div>
    </div>

    <div v-if="!isHidden" class="key-points">
      <h2>回答重点</h2>
      <div class="content">
        <p>{{ parse }}</p>
      </div>
    </div>

    <div v-else class="hidden-content">
      <div class="hidden-icon">
        <svg width="80" height="80" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
          <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
          <line x1="1" y1="1" x2="23" y2="23"></line>
        </svg>
      </div>
      <div class="hidden-text">答案已隐藏</div>
      <button class="show-btn" @click="toggleHideAnswer">显示答案</button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

// 定义 props 接收解析内容
defineProps({
  parse: {
    type: String,
    default: ''
  }
})

const isHidden = ref(false)

const toggleHideAnswer = () => {
  isHidden.value = !isHidden.value
}
</script>

<style scoped>
.answer-key {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  padding: 20px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tabs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
}

.tab {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  position: relative;
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -11px;
  left: 0;
  width: 100%;
  height: 1px;
  background: #00ff00;
  opacity: 0.8;
}

.hide-answer {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.65);
}

.hide-answer:hover {
  color: #fff;
}

.key-points h2 {
  font-size: 20px;
  margin-bottom: 16px;
  color: rgba(255, 255, 255, 0.95);
}

.content {
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.6;
}

.content p {
  margin-bottom: 12px;
}

.link {
  color: #00ff00;
  text-decoration: none;
  opacity: 0.8;
}

.link:hover {
  text-decoration: underline;
  opacity: 1;
}

.performance-list {
  margin: 12px 0;
  padding-left: 20px;
}

.performance-list li {
  margin-bottom: 8px;
  position: relative;
}

.performance-list li::before {
  content: '•';
  position: absolute;
  left: -15px;
  color: #00ff00;
  opacity: 0.8;
}

.icon-eye {
  display: inline-block;
  width: 16px;
  height: 16px;
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
}

.icon-eye::before {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* 隐藏状态的样式 */
.hidden-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  color: rgba(255, 255, 255, 0.5);
}

.hidden-icon {
  margin-bottom: 16px;
  opacity: 0.3;
}

.hidden-icon svg {
  stroke: #00ff00;
}

.hidden-text {
  font-size: 16px;
  margin-bottom: 24px;
}

.show-btn {
  background: rgba(0, 255, 0, 0.15);
  color: #00ff00;
  border: 1px solid rgba(0, 255, 0, 0.3);
  padding: 8px 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.show-btn:hover {
  background: rgba(0, 255, 0, 0.25);
  border-color: rgba(0, 255, 0, 0.5);
}
</style> 